﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using HiTeachers.Entities;
using HiTeachers.Services;

namespace HiTeachers.Web
{
    public partial class AdminPage : MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var path = Request.AppRelativeCurrentExecutionFilePath;
            path = path.Substring(path.LastIndexOf('/') + 1);
            foreach (MenuItem item in mnuMain.Items)
            {
                item.Selected = item.NavigateUrl.Equals(path, StringComparison.InvariantCultureIgnoreCase);
            }

            if (Page.IsPostBack || !Page.User.Identity.IsAuthenticated) return;

            string userName = Page.User.Identity.Name;
            Teacher teacher = TeacherServices.GetUser(userName);
            ltrAccount.Text = teacher.Name;
        }
    }
}
